import dayjs from "dayjs";
import isBetween from "dayjs/plugin/isBetween";
// dayjs.extend(isBetween);
//判断字符出现的次数
export const getCharCount = (str, charToCount) => {
	let count = 0;
	for (let i = 0; i < str.length; i++) {
		if (str[i] === charToCount) {
			count++;
		}
	}
	return count;
};

// 格式化时间
export const formatTime = (timestamp) => dayjs(timestamp).format("HH:mm:ss");

export const formatDateTime = (timestamp) =>
	timestamp ? dayjs(timestamp).format("YYYY-MM-DD HH:mm:ss") : "";

// 日期更改格式
export const changeDataFormat = (date) => {
	const alldata = '20' + date.slice(0, 6)
	const first = alldata.slice(0, 4)
	const second = alldata.slice(4, 6)
	const third = alldata.slice(6, 8)
	return first + '/' + second + '/' + third
}